package com.daocao.auth.controller;


import com.daocao.common.entity.dto.LoginDto;
import com.daocao.common.response.DaoCaoResult;
import com.daocao.common.service.AuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("auth")
public class AuthController {

    private final AuthService authService;

    public AuthController(AuthService authService) {
        this.authService = authService;
    }

    @PostMapping("sys")
    public DaoCaoResult sysLogin(@RequestBody LoginDto loginDto) {
        String token = authService.login(loginDto);

        return DaoCaoResult.success().put("token", token);
    }

}
